<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<head>
	<style type="text/css">
	body { font-family:"华文楷体";
           color:blue;
            font-size:30px;
     }
     </style>
</head>
  
          	 	


<%
	
    Connection con;
    Statement sql; 
    ResultSet rs;
    try{  Class.forName("com.mysql.jdbc.Driver");
    }
    catch(Exception e){
       out.println("忘记把MySQL数据库的JDBC-数据库驱动程序复制到JDK的扩展目录中");
    }
    String uri= "jdbc:mysql://127.0.0.1/menu";
    String user="root";
    String password="";
    con=DriverManager.getConnection(uri,user,password);
	 sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
	                        ResultSet.CONCUR_READ_ONLY);
     
    
     String type = request.getParameter("type") ;
    
    
	 rs=sql.executeQuery("SELECT * FROM "+type);
		
	 
		 ResultSetMetaData metaData = rs.getMetaData();
		 int columnCount = metaData.getColumnCount(); //得到结果集的列数
		
		 rs.beforeFirst();
         int i=0;
          int r=1;
         int  price=0;
          out.print("<form action='order.jsp' method=post>");
         while(rs.next()){
        	
        	
        	 out.print(rs.getString(1)+rs.getString(2)+rs.getString(3));
        	 String pic="<img src='image/"+type+"/"+r+".jpg' width=60,hight=60>";
          	  out.print(pic);

              int a = Integer.valueOf(rs.getString(3));

              
              price=price+a;
              
          	 
          	  
             /**for(int k=0;k<columnCount;k++) 
              {   
           	  String pic="<img src='image/1.jpg'>";
           	  out.print(pic);
           	   out.print(rs.getString(k+1));
           	   
              }
           
        */
        %>
           <body style="background:url(image/2.jpg) ;
           background-size:cover;">
        
           
          
             <input type="checkbox" name="checkbox"  value="<%
        	 out.print(rs.getString(1)+rs.getString(2)+rs.getString(3));
        	
          	  out.print(pic);
          	  out.print("<br>");
          	 out.print("总共消费"+price+"元");
          	out.print("<br>");
          	 %>">
          	 
            
        <%
           out.print("<br>");
          r++;
          i++;
         
          

         }
         
         
        %>
        
          	
         <br><input type="submit" name="b" value="加入购物车">
  
     </body>
   
         
         <% 
        
          con.close();
          %>
       

